    # 用于存储MongoDB客户端实例
    _db_client = None

    def init_database(app):
        """初始化MongoDB数据库连接"""
        global _db_client
        try:
            # ... existing code ...

    def get_db_client():
        """获取MongoDB客户端实例"""
        return _db_client
